<<<<<<< HEAD
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class TestBF extends MY_Controller {
	
	function __construct() {
		parent::__construct ();
	}
	
	
	function test(){
		$this->load->library ( 'func' );
		$active_id = urlencode ( $this->func->authcode ( "000004", "ENCODE" ) );
		echo $active_id;
		//推广链接：
		//000001:bf62bKogVfbyBQkFv%2FjhciqT4RfY%2B2SR2TKRpIu9JQ6fLO4
		//000002:58f0GVq3W567jCBglsEjjMd7tocqzWjqfsCg%2F%2BxCBN8aGXc
		//000003:6313NyeUnjUdaykuVIR6XXkYHRv26iITpeY%2Fx8Acs8p1Rjg
		//000004:b743nw2K25YY3%2FRJya6iLD5PxPCorMhzqocKRJe2CfyflrA
		
	}

	
	/**
	 * 绑定宝付账户（页面接口）
	 * 
	 * */
	function bindByPage(){
		$this->load->library('baofooSdk/baofooRequestService','br');
		$config2['bf_account'] = "13682376337";
		$config2['name'] = "刘冰";
		$config2['id_card'] = "430381198909223630";
		$config2['user_id'] = "20141230";
		$config2['return_url'] = "http://www.baidu.com";
		$config2['page_url'] = "http://www.qq.com";
		
		$this->load->library('baofooSdk/dto/request/bindBaofooPage',$config2,'bindPage');
		
		$this->br->page_BindBaofooAccount($this->bindPage);
		
	
	}
	
	
	/**
	 * 绑定宝付账户（服务端接口）
	 * 
	 * */
	function bindBySer(){
		
		$config['testMode'] = true;
		$config['signKey'] = 'n725d5gsb7mlyzzw';
		$config['terminalId']  = '100000701';
		$config['merchantId']  = '100000675';
		$this->load->library('baofooSdk/baofooRequestService',$config,'br');
		$config1['has_bf_account'] = "0";// 是否已有宝付会员账号
		$config1['bf_account'] = "13825162210";
		$config1['user_id']= "20141212903";
		$config1['real_name'] = "王力慧";
		$config1['id_card'] = "360722198907174522";
		$config1['bind_code'] = "0";
		$config1['account_type'] = "1";
		$this->load->library('baofooSdk/dto/request/bindBaofooDto',$config1,'bindDto');
		echo json_encode($this->br->api_QuickBind($this->bindDto));
	}
	
	
		
	function zhs_tender(){
		$id 				= 2;
		$account 			= 10000;
		//$paypassword 		= $this->input->post("paypassword");
		$red_money			= 1;

		$this->load->model('User_model');
		$this->load->model('Borrow_model');
		$this->load->model('Account_model');
		$user['user_id'] = 10057;
		//获取标信息
		$borrow_obj = $this->Borrow_model->get_borrow_obj($id, array('select'=>1));
		$user = $this->User_model->get_username_by_id($user['user_id']);
		//验证支付密码
		//$pay_result = $this->User_model->check_paypassword($user['user_id'], $paypassword);
		//验证提交参数
		
		//****** by liub 
		
		// 封装参数
		$data['id'] 		= $id;
		$data['money'] 		= $account;
		$data['ip'] 		= $this->input->ip_address();
		$data['user_id'] 	= $user['user_id'] ;
		

		$data['borrow_id'] 	= $id;
		// 如果用户投资的金额
		
		$user_account = $this->Account_model->get_account($data['user_id']);
		
		$account = round($account, 2);
		$account = max(0, $account);
		$account = min($account, $user_account['use_money']);
		//使用代金卷
		if(isset($red_money) && $red_money == "1"){
			$red = floor($account / 200);
			$red = max(0, $red);
			$red = min($red, $user_account['red_money']);
			/*begin tangc 20150104 限制代金卷的激活*/
			//获取激活代金卷总额
			$this->load->model('Accountlog_model', 'accountlog');
			$red_sum = $this->accountlog->get_sum_type($user['user_id'],REDPACKAGE_DEDUCT);
			$money_sum  = $red_sum*200;
			$key_money = $user_account['total'] - $money_sum;
			if($key_money > 0){
				if($key_money > $user_account['use_money']) $key_money = $user_account['use_money'];
			}
			else $key_money = 0;
			$key_red = floor($key_money/200);
			$red = min($key_red,$red);
			/*end */
			$data['red_money'] 	= $red;
		}
		$data['account'] 	= $account;
		//防止重复提交订单

	//	if($local_smscode == $smscode){
			//$this->session->unset_userdata('smscode'.$user ['id']);
			//****** 20141208 by liub 投标(兼容及时、起始计息)
			
			//echo $account ;exit;
			$flag = $this->Borrow_model->borrow_tender($data);
			if($flag == 1){
				//发放代金券
				$this->load->model('Redmanagement_model', 'redmanagement');
				$this->redmanagement->send_red($data['user_id'],6,"投标".$id."期获得奖励");
				$title = "<a  href='/borrow/zhs_obj/".$data['borrow_id']."'>第".$data['borrow_id']."期</a>";
				$this->send_msg(array('user_id'=>$user['user_id'],'sys_id'=>25,'money'=>$account,'title'=>$title));//购买成功站内信
				echo 1;	
			}else{
				echo "投标失败";	
			}
		//}
	
	}
	
	
	
	
	
	
	
	
=======
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class TestBF extends MY_Controller {
    
	function __construct() {
		parent::__construct ();
	}
	
	
	function test(){
		$this->load->library ( 'func' );
		$active_id = urlencode ( $this->func->authcode ( "000004", "ENCODE" ) );
		echo $active_id;
		//推广链接：
		//000001:bf62bKogVfbyBQkFv%2FjhciqT4RfY%2B2SR2TKRpIu9JQ6fLO4
		//000002:58f0GVq3W567jCBglsEjjMd7tocqzWjqfsCg%2F%2BxCBN8aGXc
		//000003:6313NyeUnjUdaykuVIR6XXkYHRv26iITpeY%2Fx8Acs8p1Rjg
		//000004:b743nw2K25YY3%2FRJya6iLD5PxPCorMhzqocKRJe2CfyflrA
		
	}

	
	/**
	 * 绑定宝付账户（页面接口）
	 * 
	 * */
	function bindByPage(){
		$this->load->library('baofooSdk/baofooRequestService','br');
		$config2['bf_account'] = "13682376337";
		$config2['name'] = "刘冰";
		$config2['id_card'] = "430381198909223630";
		$config2['user_id'] = "20141230";
		$config2['return_url'] = "http://www.baidu.com";
		$config2['page_url'] = "http://www.qq.com";
		
		$this->load->library('baofooSdk/dto/request/bindBaofooPage',$config2,'bindPage');
		
		$this->br->page_BindBaofooAccount($this->bindPage);
		
	
	}
	
	
	/**
	 * 绑定宝付账户（服务端接口）
	 * 
	 * */
	function bindBySer(){
		
		$config['testMode'] = true;
		$config['signKey'] = 'n725d5gsb7mlyzzw';
		$config['terminalId']  = '100000701';
		$config['merchantId']  = '100000675';
		$this->load->library('baofooSdk/baofooRequestService',$config,'br');
		$config1['has_bf_account'] = "0";// 是否已有宝付会员账号
		$config1['bf_account'] = "13825162210";
		$config1['user_id']= "20141212903";
		$config1['real_name'] = "王力慧";
		$config1['id_card'] = "360722198907174522";
		$config1['bind_code'] = "0";
		$config1['account_type'] = "1";
		$this->load->library('baofooSdk/dto/request/bindBaofooDto',$config1,'bindDto');
		echo json_encode($this->br->api_QuickBind($this->bindDto));
	}
	
	
		
	function zhs_tender(){
		$id 				= 2;
		$account 			= 10000;
		//$paypassword 		= $this->input->post("paypassword");
		$red_money			= 1;

		$this->load->model('User_model');
		$this->load->model('Borrow_model');
		$this->load->model('Account_model');
		$user['user_id'] = 10057;
		//获取标信息
		$borrow_obj = $this->Borrow_model->get_borrow_obj($id, array('select'=>1));
		$user = $this->User_model->get_username_by_id($user['user_id']);
		//验证支付密码
		//$pay_result = $this->User_model->check_paypassword($user['user_id'], $paypassword);
		//验证提交参数
		
		//****** by liub 
		
		// 封装参数
		$data['id'] 		= $id;
		$data['money'] 		= $account;
		$data['ip'] 		= $this->input->ip_address();
		$data['user_id'] 	= $user['user_id'] ;
		

		$data['borrow_id'] 	= $id;
		// 如果用户投资的金额
		
		$user_account = $this->Account_model->get_account($data['user_id']);
		
		$account = round($account, 2);
		$account = max(0, $account);
		$account = min($account, $user_account['use_money']);
		//使用代金卷
		if(isset($red_money) && $red_money == "1"){
			$red = floor($account / 200);
			$red = max(0, $red);
			$red = min($red, $user_account['red_money']);
			/*begin tangc 20150104 限制代金卷的激活*/
			//获取激活代金卷总额
			$this->load->model('Accountlog_model', 'accountlog');
			$red_sum = $this->accountlog->get_sum_type($user['user_id'],REDPACKAGE_DEDUCT);
			$money_sum  = $red_sum*200;
			$key_money = $user_account['total'] - $money_sum;
			if($key_money > 0){
				if($key_money > $user_account['use_money']) $key_money = $user_account['use_money'];
			}
			else $key_money = 0;
			$key_red = floor($key_money/200);
			$red = min($key_red,$red);
			/*end */
			$data['red_money'] 	= $red;
		}
		$data['account'] 	= $account;
		//防止重复提交订单

	//	if($local_smscode == $smscode){
			//$this->session->unset_userdata('smscode'.$user ['id']);
			//****** 20141208 by liub 投标(兼容及时、起始计息)
			
			//echo $account ;exit;
			$flag = $this->Borrow_model->borrow_tender($data);
			if($flag == 1){
				//发放代金券
				$this->load->model('Redmanagement_model', 'redmanagement');
				$this->redmanagement->send_red($data['user_id'],6,"投标".$id."期获得奖励");
				$title = "<a  href='/borrow/zhs_obj/".$data['borrow_id']."'>第".$data['borrow_id']."期</a>";
				$this->send_msg(array('user_id'=>$user['user_id'],'sys_id'=>25,'money'=>$account,'title'=>$title));//购买成功站内信
				echo 1;	
			}else{
				echo "投标失败";	
			}
		//}
	
	}
	
	
	
	
	
	
	
	
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}